
// import { useSelector } from "react-redux"

// export default (props) => {
//     let { size } = useSelector(function (state) {
//         // console.log("获取仓库中的状态：", state);
//         return state.app
//     })
//     let { token, userInfo, accessRoutes } = useSelector(function (state) {
//         return state.user
//     })
//     console.log("size:", size);
//     console.log("token:", token);
//     console.log("userInfo:", userInfo);
//     console.log("accessRoutes:", accessRoutes);
//     return (
//         <div>
//             <h2>商品管理</h2>
//             <h2>{size}</h2>
//         </div>
//     )
// }


import { useSelector, useDispatch } from "react-redux"

export default (props) => {

    const { size } = useSelector(state => state.app)
    const { token, userInfo, accessRoutes } = useSelector(state => state.user)
    const dispatch = useDispatch();

    console.log("size:", size);
    console.log("token:", token);
    console.log("userInfo:", userInfo);
    console.log("accessRoutes:", accessRoutes);

    const sizeAdd = () => {
        // 派发一个action 
        // APP_SIZE_ADD 是一个信号 
        dispatch({ type: "APP_SIZE_ADD", payload: 2 })
    }
    const sizeSub = () => {
        dispatch({ type: "APP_SIZE_SUB", payload: 3 })
    }
    return (
        <div>
            <h2>商品管理</h2>
            <h2>{size}</h2>
            <button onClick={sizeAdd}>size++</button>
            <button onClick={sizeSub}>size--</button>
        </div>
    )
}